package sctu.edu.java.year2016.team02.zhoujie.day20160522.chapter4_2;

/**
 * Created by ACER on 2016/5/23.
 *//*编写java程序，利用for循环打印菱形*/
public class Rhombus {
    public static void main(String[] args) {
        int hangshu = 11;
        int yiban = hangshu / 2 + 1;
        int yibanduo = hangshu / 2;
        System.out.println("空心菱形：");
        for (int k = 1; k <= yiban; k++) {
            for (int i = 1; i <= (yiban - k); i++) {
                System.out.print(" ");
            }
            System.out.print("*");
            for (int i = 1; i <= ((k - 2) * 2 + 1); i++) {
                System.out.print(" ");
            }
            if (k != 1) {
                System.out.print("*");
            }
            System.out.println();
        }
        for (int k = yibanduo; k >= 1; k--) {
            for (int i = 1; i <= (yiban - k); i++) {
                System.out.print(" ");
            }
            System.out.print("*");
            for (int i = 1; i <= ((k - 2) * 2 + 1); i++) {
                System.out.print(" ");
            }
            if (k != 1) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}


